package com.yc.scott.ui;

import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.Color;

public class Panel背景 {

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Panel背景 window = new Panel背景();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Panel背景() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 646, 536);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JPanel panel = new JPanel() {
			 @Override
			    protected void paintComponent(Graphics g) {
				 super.paintComponent(g);
					Image backgroundImage;
					try {
						backgroundImage = ImageIO.read(new File("E:\\bg.jpg"));
						g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), this);
					} catch (IOException e) {
						e.printStackTrace();
					}
			    }
		};
		panel.setBounds(40, 48, 412, 259);
		frame.getContentPane().add(panel);
		
		JButton btnNewButton = new JButton("New button");
		panel.add(btnNewButton);
		
		JLabel lblNewLabel_1 = new JLabel("New label");
		lblNewLabel_1.setForeground(new Color(255, 255, 0));
		lblNewLabel_1.setBackground(new Color(255, 128, 0));
		lblNewLabel_1.setOpaque(true);
		panel.add(lblNewLabel_1);
	}
}
